package xyz.riceball.security.authorization;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.config.annotation.ObjectPostProcessor;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;

/**
 * <p>
 * 增强类
 * </p>
 *
 * @author xiaovcloud
 * @since 2022/4/27 22:15
 */
@Getter
@Setter
public class RiceBallObjectPostProcessor implements ObjectPostProcessor<FilterSecurityInterceptor> {

    @Override
    public <O extends FilterSecurityInterceptor> O postProcess(O o) {
        RiceBallAccessDecisionManager decisionManager = new RiceBallAccessDecisionManager();
        o.setAccessDecisionManager(decisionManager);

        RiceBallFilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource =
                new RiceBallFilterInvocationSecurityMetadataSource();
        o.setSecurityMetadataSource(filterInvocationSecurityMetadataSource);

        return o;
    }

}
